
import os
import sys
import json
import csv


def make_separation_label(match_list, csv_path, temp_path, new_temp_path):
    '''
        make a CSV file from match list
        format:
            source path, person ID, target path, no-use
        
        in the next stage, file in source path will be rename and
        move to target path
    '''

    csvFile = open(csv_path, "w")
    writer = csv.writer(csvFile)

    fileHeader = ['noise_utterance','emb_utterance_id','clean_utterance','clean2_utterance']
    writer.writerow(fileHeader)

    position_list = ['left', 'middle', 'right']
    for idx in range(len(match_list)):
        for position in range(3):
            data = [
                os.path.join(temp_path, match_list[idx][0][position]),
                match_list[idx][1][position], 
                os.path.join(new_temp_path, str(idx+1).zfill(3) + '_' + position_list[position] + '.wav'),
                'no-use']
            writer.writerow(data)
